package service

import (
	"awesomeProject/app/model"
	"awesomeProject/app/request"
	"awesomeProject/app/response"
	"awesomeProject/global"
	"context"
	"go.mongodb.org/mongo-driver/bson"
)

type OrderItemCurrentSrv struct{}

func (o OrderItemCurrentSrv) OrderItemCurrent(req request.OrderItemCurrent) response.Resp {
	filter := bson.D{
		//{"shop_id", req.ShopId},
		{"orderSn", req.OrderSn},
		{"recordId", req.RecordId},
	}
	var overview model.OrderItemCurrent
	err := global.MongoDB.Collection("order_item_current").FindOne(context.TODO(), filter).Decode(&overview)
	if err != nil {
		return response.ErrQuery.SetMsg(err.Error())
	}

	return response.OK.WithData(overview)
}
